home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / comm1 / qwesorcs.lha / qwe_sources / Flut!v4 / Flut.c < prev    next >
Text File  |  1996-03-24  |  36KB  |  1,968 lines

  1. const char *_VERSION="\0$VER: Flut! 4.0a (23.03.96)";
  2. #include <cnet/empty.h>
  3. #include <dos/dos.h>
  4. #include "Flut.h"
  5.  
  6. #define mainansi    0
  7. #define titelansi    1
  8. #define winneransi    2
  9. #define loseransi    3
  10. #define helpansi    4
  11. #define layoutansi    5
  12. #define joinansi    6
  13. #define hallansi    7
  14. #define wallansi    8
  15. #define messansi    9
  16. #define rankansi    10
  17. #define chefansi    11
  18. #define testansi    12
  19. #define wallspfad    13
  20. #define flutserver    14
  21.  
  22. FILE    *fp;
  23.  
  24. struct tm*datum_zeit;
  25.  
  26. void    send_message(long com);
  27.  
  28. void    flute(BYTE xpos, BYTE ypos);
  29. void    fuelle(BYTE xpos, BYTE ypos);
  30. void    print_fuellgrad(BYTE xt, BYTE yt, BYTE akt_usert, BYTE fuellgrad);
  31.  
  32. void    print_players(void);
  33. void    print_games(void);
  34. void    print_brett(void);
  35. void    print_status(void);
  36. void    print_action(void);
  37. void    print_titel(void);
  38. void    print_clock(void);
  39. void    print_ranks(void);
  40. void    print_hall(void);
  41.  
  42. void    fluter(long fluterid);
  43. void    operator(void);
  44. void    selectorjoin(void);
  45. void    joiner(void);
  46. void    returner(void);
  47. void    pointeradd(void);
  48. void    print_changes(void);
  49. void    count_eimer(void);
  50. void    killgame(void);
  51. void    scrollx(UBYTE line,char *text);
  52. void    scrolly(char *text);
  53. void    mymain(void);
  54. void    select(void);
  55. void    get_wall(void);
  56. void    cursor(void);
  57. void    make_path(byte pathnr);
  58.  
  59. char    line_a[500],*p,line_b[500],*p2,
  60.         batzen[7]="°°²²ÛÛ",
  61.         leer[2]=" ",
  62.         taker[23],
  63.         key[3],
  64.         last_tag[3],
  65.         today_tag[3],
  66.         next_tag[3],
  67.         next_hh_mm[6],
  68.         last_faktor_char[8],
  69.         username[6][21],
  70.         wall[12][59],
  71.         routepfad[21]=    "mail:users/cr.fluter";
  72.  
  73. char    path[15][21]={    "ansis/main",    "ansis/titel.  ",    "ansis/winner.  ",    "ansis/loser.  ",
  74.                         "ansis/help. ",    "ansis/layout",        "ansis/join",        "ansis/hall",
  75.                         "ansis/wall",    "ansis/mess",        "ansis/rank",        "ansis/chef",
  76.                         "ansis/test",    "walls/  ",            "flut-server"},
  77.         pathstart[108],
  78.         pathwork[108];
  79.  
  80. UBYTE    x,y,i,j,k,
  81.         xtab,ytab,
  82.         altx,alty,
  83.         akt_user,
  84.         stacker,
  85.         infoline=11,
  86.         colorcycle,
  87.         farbe,
  88.         olmyeah,
  89.         anz_angefasst,
  90.         anz_eimer[3][6],
  91.         max_eimer,
  92.         groesster,
  93.         zweiter,
  94.         gesamt_voll,
  95.         titelmax,
  96.         winnermax,
  97.         losermax;
  98.  
  99. BYTE    moremode,
  100.         starts,
  101.         x_flut[128],
  102.         y_flut[128],
  103.         game=-1,
  104.         game_print=0,
  105.         game_neu,
  106.         game_sysop;
  107.  
  108. int        wertung_a,wertung_b;
  109.  
  110. ULONG    today,
  111.         rechen,
  112.         nearest;
  113.  
  114. BPTR    lock;
  115.  
  116. BOOL    turn[60],join[60],
  117.         rankyes,
  118.         ansidesign=TRUE,
  119.         ready,
  120.         reading,
  121.         go;
  122.  
  123. FLOAT    last_faktor;
  124.  
  125. struct tabellenstruct
  126. {
  127.     LONG    wert,
  128.             ptr;
  129. }tab[12];
  130.  
  131. main(int argc,char **argv)
  132. {
  133.     PreMain(argc,argv);
  134.  
  135.     if(argc!=5)
  136.     {
  137.         PutText("n1Arguments for Flut!n1-------------------n2Number of Titelansisn1Number of Winneransisn1Number of Loseransisn2");
  138.     }
  139.     else
  140.     {
  141.         titelmax=atoi(argv[2]);
  142.         winnermax=atoi(argv[3]);
  143.         losermax=atoi(argv[4]);
  144.  
  145.         srand(time(NULL));
  146.     
  147.         if(z->user1.TermLength<30 || z->user1.TermWidth<80 || z->user1.Colors==0 || z->user1.ANSI<2)
  148.         {
  149.             PutText("n1Requirements for Flut!n1----------------------n2Ansi 8/16 Coloursn1IBM-Fontn180 Columnsn130 Linesn2");
  150.         }
  151.         else
  152.         {
  153.             lock=GetProgramDir();
  154.             NameFromLock(lock,pathstart,108);
  155.  
  156.             make_path(mainansi);
  157.             ReadFile(pathwork,0);
  158.  
  159.             make_path(flutserver);
  160.             sprintf(line_a,"run %s",pathwork);
  161.  
  162.             while(!flutport && starts<5)
  163.             {
  164.                 Forbid();
  165.                 if(flutport=FindPort(FLUT_PORT))
  166.                 {
  167.                     if(ptr=(struct messagestruct *)AllocVec(sizeof(struct messagestruct),MEMF_PUBLIC))
  168.                     {
  169.                         if(flutreplyport=CreatePort(NULL,0))
  170.                         {
  171.                             strcpy(ptr->pname,z->user1.Handle);
  172.                             send_message(MSG_INIT);
  173.                             Permit();
  174.                             mymain();
  175.                             send_message(MSG_QUIT);
  176.                             DeletePort(flutreplyport);
  177.                         }
  178.                         FreeVec(ptr);
  179.                     }
  180.                 }
  181.                 else
  182.                 {
  183.                     Permit();
  184.                     system(line_a);
  185.                     starts++;
  186.                     Delay(25);
  187.                 }
  188.             }
  189.             PutText("1H");
  190.         }
  191.     }
  192.     PostMain();
  193. }
  194.  
  195. void send_message(long com)
  196. {
  197.     ptr->msg.mn_Node.ln_Pri=0;
  198.     ptr->msg.mn_Node.ln_Name=NULL;
  199.     ptr->msg.mn_Node.ln_Type=NT_MESSAGE;
  200.     ptr->msg.mn_ReplyPort=flutreplyport;
  201.     ptr->msg.mn_Length=sizeof(struct messagestruct);
  202.     ptr->com=com;
  203.     PutMsg(flutport,(struct messagestruct *)ptr);
  204.     WaitPort(flutreplyport);
  205.     while(ptrreply=(struct Message *)GetMsg(flutreplyport))
  206.     {
  207.     }
  208. }
  209.  
  210. void make_path(byte pathnr)
  211. {
  212.     strcpy(pathwork,pathstart);
  213.     AddPart(pathwork,path[pathnr],108);
  214. }
  215.  
  216. void scrollx(UBYTE line, char *text)
  217. {
  218.     char    string[20],*pstring;
  219.     pstring=text;
  220.  
  221.     if(colorcycle==7)
  222.     {
  223.         colorcycle=1;
  224.     }
  225.     else
  226.     {
  227.         colorcycle++;
  228.     }
  229.  
  230.     sprintf(string,"%d;1HPC%d",line,colorcycle);
  231.     PutText(string);
  232.  
  233.     while(*pstring)
  234.     {
  235.         if(*pstring==25)
  236.         {
  237.             sprintf(string,"%d;1HPC%4.4s",line,pstring);
  238.             pstring+=4;
  239.         }
  240.         else
  241.         {
  242.             sprintf(string,"%d;1HPC%1.1s",line,pstring);
  243.             pstring++;
  244.         }
  245.         PutText(string);
  246.     }
  247. }
  248.  
  249. void scrolly(char *text)
  250. {
  251.     PutText("1HM1H");
  252.     PutText(text);
  253. }
  254.  
  255. void gettime(void)
  256. {
  257.     time(&today);
  258.     datum_zeit=localtime(&today);
  259.     strftime(today_tag,3,"%d",datum_zeit);
  260. }
  261.  
  262. void print_games(void)
  263. {
  264.     gettime();
  265.     PutText("H");
  266.     nearest=0;
  267.     for(y=0;y<51;y+=10)
  268.     {
  269.         p=stpcpy(line_a,"\nC");
  270.         for(x=0;x<10;x++)
  271.         {
  272.             join[y+x]=FALSE;
  273.             turn[y+x]=FALSE;
  274.             if(ptr->all->game[y+x].anzahl==0)
  275.             {
  276.                 join[y+x]=TRUE;
  277.                 farbe=36; /* empty */
  278.             }
  279.             else
  280.             {
  281.                 farbe=35; /* out */
  282.                 for(i=0;i<6;i++)
  283.                 {
  284.                     if(ptr->all->game[y+x].player[i].userid==z->id)
  285.                     {
  286.                         if(ptr->all->game[y+x].player[ptr->all->game[y+x].anzahl-1].userid==0)
  287.                         {
  288.                             farbe=34; /* joined */
  289.                         }
  290.                         else
  291.                         {
  292.                             datum_zeit=localtime(&ptr->all->game[y+x].player[i].last_move);
  293.                             strftime(last_tag,3,"%d",datum_zeit);
  294.                             if(today-ptr->all->game[y+x].player[i].last_move>43200 && strcmp(today_tag,last_tag)!=0 && y+x<50)
  295.                             {
  296.                                 turn[y+x]=TRUE;
  297.                                 farbe=31; /* turn */
  298.                             }
  299.                             else
  300.                             {
  301.                                 turn[y+x]=FALSE;
  302.                                 farbe=33; /* in */
  303.                                 if(y+x<50)
  304.                                 {
  305.                                     if(nearest>ptr->all->game[y+x].player[i].last_move+43200 || nearest==0)
  306.                                     {
  307.                                         nearest=ptr->all->game[y+x].player[i].last_move+43200;
  308.                                     }
  309.                                 }
  310.                             }
  311.                             for(j=0;j<ptr->all->game[y+x].y_size;j++)
  312.                             {
  313.                                 for(k=0;k<ptr->all->game[y+x].x_size;k++)
  314.                                 {
  315.                                     if(ptr->all->game[y+x].fuellgrad[k][j]==0 || (ptr->all->game[y+x].farbe[k][j]==i+1 && ptr->all->game[y+x].fuellgrad[k][j]<3))
  316.                                     {
  317.                                         goto found;
  318.                                     }
  319.                                 }
  320.                             }
  321.                             turn[y+x]=FALSE;
  322.                             farbe=37;
  323.                             found:
  324.                         }
  325.                     }
  326.                 }
  327.                 if(farbe==35 && ptr->all->game[y+x].player[ptr->all->game[y+x].anzahl-1].userid==0)
  328.                 {
  329.                     join[y+x]=TRUE;
  330.                     farbe=32; /* wait */
  331.                 }
  332.             }
  333.             sprintf(line_b," %2.2dm%2.2d",farbe,y+x+1);
  334.             p=stpcpy(p,line_b);
  335.  
  336.         }
  337.         if(y<50)
  338.         {
  339.             PutText(line_a);
  340.         }
  341.     }
  342.     PutText("7H C C C C C C C C C ");
  343.  
  344.     for(y=0;y<51;y+=10)
  345.     {
  346.         for(x=0;x<10;x++)
  347.         {
  348.             if(ptr->all->game[y+x].belegt==TRUE)
  349.             {
  350.                 sprintf(line_a,"%d;%dH>",y/10+4,x*3+17);
  351.                 PutText(line_a);
  352.             }
  353.         }
  354.     }
  355. }
  356.  
  357. void print_text(byte pathnr)
  358. {
  359.     make_path(pathnr);
  360.     if(fp=fopen(pathwork,"r"))
  361.     {
  362.         while (fgets(line_a,sizeof(line_a),fp))
  363.         {
  364.             line_a[strlen(line_a)-1]=0;
  365.             scrolly(line_a);
  366.         }
  367.         fclose(fp);
  368.     }
  369. }
  370.  
  371. void count_eimer(void)
  372. {
  373.     for(y=0;y<6;y++)
  374.     {
  375.         anz_eimer[0][y]=0;
  376.         anz_eimer[1][y]=0;
  377.         anz_eimer[2][y]=0;
  378.     }
  379.  
  380.     anz_angefasst=0;
  381.     for(y=0;y<ptr->all->game[game].y_size;y++)
  382.     {
  383.         for(x=0;x<ptr->all->game[game].x_size;x++)
  384.         {
  385.             if(ptr->all->game[game].fuellgrad[x][y]>0)
  386.             {
  387.                 anz_eimer[ptr->all->game[game].fuellgrad[x][y]-1][ptr->all->game[game].farbe[x][y]-1]++;
  388.                 anz_angefasst++;
  389.             }
  390.         }
  391.     }
  392. }
  393.  
  394. void print_players(void)
  395. {
  396.     count_eimer();
  397.  
  398.     for(y=0;y<6;y++)
  399.     {
  400.         if(ptr->all->game[game].player[y].userid==0)
  401.         {
  402.             if(y<ptr->all->game[game].anzahl)
  403.             {
  404.                 sprintf(line_a,"%d;48HC%1x???????? ??? ??? ??? ???? ?????",y+4,9+y);
  405.             }
  406.             else
  407.             {
  408.                 sprintf(line_a,"%d;48HC%1x-------- --- --- --- ---- -----",y+4,9+y);
  409.             }
  410.         }
  411.         else
  412.         {
  413.             if(username[y][0]==0)
  414.             {
  415.                 ReadAccount(ptr->all->game[game].player[y].userid,&z->user2);
  416.                 strcpy(username[y],z->user2.Handle);
  417.             }
  418.             last_faktor=(today - ptr->all->game[game].player[y].last_move)/86400.0;
  419.  
  420.             if(last_faktor < 10)
  421.             {
  422.                 if(last_faktor>2.99 && last_faktor<3.0)
  423.                 {
  424.                     strcpy(last_faktor_char,"2.99");
  425.                 }
  426.                 else
  427.                 {
  428.                     sprintf(last_faktor_char,"%1.2f",last_faktor);
  429.                 }
  430.             }
  431.             else
  432.             {
  433.                 sprintf(last_faktor_char,">%3.0f",last_faktor);
  434.             }
  435.  
  436.             rechen=ptr->all->game[game].player[y].last_move;
  437.  
  438.             datum_zeit=localtime(&rechen);
  439.             strftime(next_tag,3,"%d",datum_zeit);
  440.  
  441.             rechen+=43200;
  442.  
  443.             if(ptr->all->game[game].player[ptr->all->game[game].anzahl-1].userid==0)
  444.             {
  445.                 sprintf(line_a,"%d;48HC%1x%-8.8s% 4d% 4d% 4d ----  Wait",y+4,9+y,username[y],anz_eimer[0][y],anz_eimer[1][y],anz_eimer[2][y]);
  446.             }
  447.             else
  448.             {
  449.                 if(game>49)
  450.                 {
  451.                     sprintf(line_a,"%d;48HC%1x%-8.8s% 4d% 4d% 4d ----   OLG",y+4,9+y,username[y],anz_eimer[0][y],anz_eimer[1][y],anz_eimer[2][y],last_faktor_char);
  452.                 }
  453.                 else
  454.                 {
  455.                     if(today>rechen && strcmp(today_tag,next_tag)!=0)
  456.                     {
  457.                         sprintf(line_a,"%d;48HC%1x%-8.8s% 4d% 4d% 4d %s   Now",y+4,9+y,username[y],anz_eimer[0][y],anz_eimer[1][y],anz_eimer[2][y],last_faktor_char);
  458.                     }
  459.                     else
  460.                     {
  461.                         datum_zeit=localtime(&rechen);
  462.                         strftime(next_hh_mm,6,"%H:%M",datum_zeit);
  463.  
  464.                         if(atoi(next_hh_mm)>11)
  465.                         {
  466.                             sprintf(line_a,"%d;48HC%1x%-8.8s% 4d% 4d% 4d %s 00:00",y+4,9+y,username[y],anz_eimer[0][y],anz_eimer[1][y],anz_eimer[2][y],last_faktor_char);
  467.                         }
  468.                         else
  469.                         {
  470.                             sprintf(line_a,"%d;48HC%1x%-8.8s% 4d% 4d% 4d %s %s",y+4,9+y,username[y],anz_eimer[0][y],anz_eimer[1][y],anz_eimer[2][y],last_faktor_char,next_hh_mm);
  471.                         }
  472.                     }
  473.                 }
  474.             }
  475.         }
  476.         PutText(line_a);
  477.         if(ptr->all->game[game].player[y].userid==z->id)
  478.         {
  479.             sprintf(line_a,"%d;56H<",y+4);
  480.             PutText(line_a);
  481.         }
  482.     }
  483. }
  484.  
  485. void print_brett(void)
  486. {
  487.     UBYTE colorcool;
  488.     char fuellung[14];
  489.  
  490.     if(game==-1)
  491.     {
  492.         x=rand()%titelmax;
  493.         sprintf(&path[titelansi][12],"%2.2d",x);
  494.         print_text(titelansi);
  495.         scrollx(29,"C1Welcome to Flut! C9v4C7   C2Org Kongoman C3Prg Qwert C5Ansis Miracle C6Docu Fate/1oo%   ");
  496.     }
  497.     else
  498.     {
  499.         if(join[game] && ptr->all->game[game].anzahl==0)
  500.         {
  501.             print_text(joinansi);
  502.         }
  503.         else
  504.         {
  505.             PutText("C7@2");
  506.  
  507.             y=0;
  508.             while(y<ytab)
  509.             {
  510.                 y++;
  511.                 scrolly("");
  512.             }
  513.             for(y=0;y<=ptr->all->game[game].y_size;y++)
  514.             {
  515.                 if(ansidesign || y<ptr->all->game[game].y_size)
  516.                 {
  517.                     if(xtab==0)
  518.                     {
  519.                         p=&line_a[0];
  520.                         p2=&line_b[0];
  521.                     }
  522.                     else
  523.                     {
  524.                         sprintf(line_a,"%2.2dC",xtab);
  525.                         strcpy(line_b,line_a);
  526.                         p=&line_a[5];
  527.                         p2=&line_b[5];
  528.                     }
  529.                 }
  530.                 for(x=0;x<ptr->all->game[game].x_size;x++)
  531.                 {
  532.                     if(ansidesign)
  533.                     {
  534.                         if(x==0)
  535.                         {
  536.                             if(y==0)
  537.                             {
  538.                                 p=stpcpy(p,"ÚÄÄ");
  539.                             }
  540.                             else
  541.                             {
  542.                                 if(y==ptr->all->game[game].y_size)
  543.                                 {
  544.                                     p=stpcpy(p,"ÀÄÄ");
  545.                                 }
  546.                                 else
  547.                                 {
  548.                                     p=stpcpy(p,"ÃÄÄ");
  549.                                 }
  550.                             }
  551.                         }
  552.                         else
  553.                         {
  554.                             if(y==0)
  555.                             {
  556.                                 p=stpcpy(p,"ÂÄÄ");
  557.                             }
  558.                             else
  559.                             {
  560.                                 if(y==ptr->all->game[game].y_size)
  561.                                 {
  562.                                     p=stpcpy(p,"ÁÄÄ");
  563.                                 }
  564.                                 else
  565.                                 {
  566.                                     p=stpcpy(p,"ÅÄÄ");
  567.                                 }
  568.                             }
  569.                         }
  570.                         p2=stpcpy(p2,"³  ");
  571.                     }
  572.                     else
  573.                     {
  574.                         p=stpcpy(p," _  ");
  575.                         p2=stpcpy(p2,"(_) ");
  576.                     }
  577.                 }
  578.  
  579.                 if(ansidesign)
  580.                 {
  581.                     if(y==0)
  582.                     {
  583.                         p=stpcpy(p,"¿ ");
  584.                     }
  585.                     else
  586.                     {
  587.                         if(y==ptr->all->game[game].y_size)
  588.                         {
  589.                             p=stpcpy(p,"Ù ");
  590.                         }
  591.                         else
  592.                         {
  593.                             p=stpcpy(p,"´ ");
  594.                         }
  595.                     }
  596.                     p2=stpcpy(p2,"³ ");
  597.                 }
  598.                 else
  599.                 {
  600.                     if(y<ptr->all->game[game].y_size)
  601.                     {
  602.                         p2--;
  603.                         p2=stpcpy(p2,"");
  604.                     }
  605.                 }
  606.  
  607.                 if(y<ptr->all->game[game].y_size)
  608.                 {
  609.                     *(p-1)=0;
  610.                     colorcool=0;
  611.  
  612.                     for(x=0;x<ptr->all->game[game].x_size;x++)
  613.                     {
  614.                         if(ptr->all->game[game].fuellgrad[x][y]>0)
  615.                         {
  616.                             if(colorcool==ptr->all->game[game].farbe[x][y])
  617.                             {
  618.                                 if(ansidesign)
  619.                                 {
  620.                                     sprintf(fuellung,"%dH%2.2s",x*3+2+xtab,batzen+(ptr->all->game[game].fuellgrad[x][y]-1)*2);
  621.                                 }
  622.                                 else
  623.                                 {
  624.                                     sprintf(fuellung,"%dH%d",x*4+2+xtab,ptr->all->game[game].fuellgrad[x][y]);
  625.                                 }
  626.                             }
  627.                             else
  628.                             {
  629.                                 if(ansidesign)
  630.                                 {
  631.                                     sprintf(fuellung,"%dHC%1x%2.2s",x*3+2+xtab,ptr->all->game[game].farbe[x][y]+8,batzen+(ptr->all->game[game].fuellgrad[x][y]-1)*2);
  632.                                 }
  633.                                 else
  634.                                 {
  635.                                     sprintf(fuellung,"%dHC%1x%d",x*4+2+xtab,ptr->all->game[game].farbe[x][y]+8,ptr->all->game[game].fuellgrad[x][y]);
  636.                                 }
  637.                             }
  638.                             p2=stpcpy(p2,fuellung);
  639.                             colorcool=ptr->all->game[game].farbe[x][y];
  640.                         }
  641.                     }
  642.                     scrolly(line_a);
  643.                     scrolly(line_b);
  644.                     PutText("");
  645.                 }
  646.             }
  647.             if(ansidesign)
  648.             {
  649.                 scrolly(line_a);
  650.                 y=1;
  651.             }
  652.             else
  653.             {
  654.                 y=0;
  655.             }
  656.  
  657.             while(y<ytab+1)
  658.             {
  659.                 y++;
  660.                 scrolly("");
  661.             }
  662.         }
  663.     }
  664. }
  665.  
  666. void tabulator(void)
  667. {
  668.     xtab=(80-4*ptr->all->game[game].x_size)/2;
  669.     ytab=8-ptr->all->game[game].y_size;
  670.     if(ansidesign)
  671.     {
  672.         xtab+=ptr->all->game[game].x_size/2;
  673.     }
  674. }
  675.  
  676. void selectorjoin(void)
  677. {
  678.     altx=(ptr->all->game[game].x_size-1)/2;
  679.     alty=(ptr->all->game[game].y_size-1)/2;
  680.  
  681.     for(y=0;y<6;y++)
  682.     {
  683.         for(x=0;x<21;x++)
  684.         {
  685.             username[y][x]=0;
  686.         }
  687.     }
  688.  
  689.     if(ptr->all->game[game].anzahl>0)
  690.     {
  691.         max_eimer=ptr->all->game[game].x_size*ptr->all->game[game].y_size;
  692.  
  693.         tabulator();
  694.  
  695.         wertung_a=ptr->all->game[game].x_size*ptr->all->game[game].y_size*ptr->all->game[game].anzahl/6;
  696.         wertung_b=ptr->all->game[game].x_size*ptr->all->game[game].y_size/(-6);
  697.  
  698.         sprintf(line_a,"H%3.3d/%2.2d",wertung_a,wertung_b);
  699.         PutText(line_a);
  700.     }
  701.  
  702.     akt_user=0;
  703.     while(ptr->all->game[game].player[akt_user].userid!=z->id && akt_user<6)
  704.     {
  705.         akt_user++;
  706.     }
  707.     akt_user++;
  708.  
  709.     if(game>49)
  710.     {
  711.         ptr->olgpointer=ptr->all->olg[game-50].pointer;
  712.     }
  713. }
  714.  
  715. void print_status(void)
  716. {
  717.     if(game>49) 
  718.     {
  719.         PutText("55H    ");
  720.     }
  721.     else
  722.     {
  723.         if(ptr->all->game[game].player[akt_user-1].last_wall_lese=='x' && akt_user<7)
  724.         {
  725.             PutText("55HC9WC1allC7");
  726.         }
  727.         else
  728.         {
  729.             PutText("55HCFWC7all");
  730.         }
  731.     }
  732.  
  733.     if(game_print==0 || (join[game] && ptr->all->game[game].player[0].userid==0))
  734.     {
  735.         PutText("C7H-      H-     H-  ");
  736.     }
  737.     else
  738.     {
  739.         if(ptr->all->game[game].status==8)
  740.         {
  741.             PutText("HC1X-Flut");
  742.         }
  743.         else
  744.         {
  745.             PutText("HC7Normal");
  746.         }
  747.         if(ptr->all->game[game].border==0)
  748.         {
  749.             PutText("HC1No ");
  750.         }
  751.         else
  752.         {
  753.             PutText("HC7Yes");
  754.         }
  755.     }
  756.     if(game_print>0)
  757.     {
  758.         if(join[game])
  759.         {
  760.             PutText("1HCFJC7oin game");
  761.         }
  762.         else
  763.         {
  764.             if(turn[game])
  765.             {
  766.                 sprintf(taker,"1HC%1xTC%1dake turn",akt_user+8,akt_user);
  767.                 PutText(taker);
  768.             }
  769.             else
  770.             {
  771.                 PutText("1H         ");
  772.             }
  773.         }
  774.     }
  775.     else
  776.     {
  777.         PutText("1H         ");
  778.     }
  779. }
  780.  
  781. void select()
  782. {
  783.     if(game_neu<0 || game_neu>60)
  784.     {
  785.         sprintf(line_a,"uups game %d?",game_neu);
  786.         scrollx(infoline,line_a);
  787.     }
  788.     else
  789.     {
  790.         if(game_neu==game_print)
  791.         {
  792.             sprintf(line_a,"this IS game %d!",game_neu);
  793.             scrollx(infoline,line_a);
  794.         }
  795.         else
  796.         {
  797.             game_neu--;
  798.  
  799.             ptr->game_neu=game_neu;
  800.             ptr->game_alt=game;
  801.  
  802.             send_message(MSG_GAME);
  803.  
  804.             if(ptr->result)
  805.             {
  806.                 game=game_neu;
  807.                 game_print=game+1;
  808.  
  809.                 selectorjoin();
  810.                 print_players();
  811.                 print_games();
  812.                 print_status();
  813.                 print_brett();
  814.             }
  815.             else
  816.             {
  817.                 if(game_neu>49)
  818.                 {
  819.                     scrollx(infoline,"somebody creates a new battlefield - please wait");
  820.                 }
  821.                 else
  822.                 {
  823.                     scrollx(infoline,"sorry - in use!");
  824.                 }
  825.             }
  826.         }
  827.     }
  828.     sprintf(line_a,"HC7%2.2d",game_print);
  829.     PutText(line_a);
  830. }
  831.  
  832. void print_clock (void)
  833. {
  834.     time(&today);
  835.     datum_zeit=localtime(&today);
  836.     strftime(line_a,12,"Time %H:%M ",datum_zeit);
  837.  
  838.     p=&line_a[11];
  839.     p=stpcpy(p,"NextTurn ");
  840.     if(nearest==0)
  841.     {
  842.         stpcpy(p,"??:??");
  843.     }
  844.     else
  845.     {
  846.         datum_zeit=localtime(&nearest);
  847.         strftime(next_hh_mm,6,"%H:%M",datum_zeit);
  848.         if(atoi(next_hh_mm)>11)
  849.         {
  850.             stpcpy(p,"00:00");
  851.         }
  852.         else
  853.         {
  854.             stpcpy(p,next_hh_mm);
  855.         }
  856.     }
  857.     scrollx(infoline,line_a);
  858. }
  859.  
  860. void pointeradd(void)
  861. {
  862.     if(ptr->pointer==9?(ptr->pointer=0):(ptr->pointer++));
  863. }
  864.  
  865. void print_changes(void)
  866. {
  867.     if(z->OLMWaiting!=olmyeah)
  868.     {
  869.         olmyeah=z->OLMWaiting;
  870.         if(olmyeah==1)
  871.         {
  872.             scrollx(infoline,"1 OLM waiting");
  873.         }
  874.         else
  875.         {
  876.             sprintf(line_a,"%d OLM's waiting",olmyeah);
  877.             scrollx(infoline,line_a);
  878.         }
  879.     }
  880.  
  881.     while(ptr->pointer!=ptr->all->pointer)
  882.     {
  883.         scrollx(infoline,ptr->all->mails[ptr->pointer]);
  884.         pointeradd();
  885.     }
  886.  
  887.     if(game>49 && !reading)
  888.     {
  889.         while(ptr->olgpointer!=ptr->all->olg[game-50].pointer)
  890.         {
  891.             ptr->olgpointer++;
  892.             print_fuellgrad(ptr->all->olg[game-50].fluter[ptr->olgpointer].xpos,ptr->all->olg[game-50].fluter[ptr->olgpointer].ypos,ptr->all->olg[game-50].fluter[ptr->olgpointer].akt_user,ptr->all->olg[game-50].fluter[ptr->olgpointer].fuellgrad);
  893.             PutText("U0");
  894.             print_players();
  895.         }
  896.  
  897.         if(akt_user<7)
  898.         {
  899.             if(akt_user==ptr->all->olg[game-50].akt_user && !turn[game])
  900.             {
  901.                 print_players();
  902.                 sprintf(taker,"1HC%1xTC%1dake turn",akt_user+8,akt_user);
  903.                 PutText(taker);
  904.                 turn[game]=TRUE;
  905.             }
  906.  
  907.             if(ptr->all->olg[game-50].status[akt_user-1]==1)
  908.             {
  909.                 ptr->all->olg[game-50].status[akt_user-1]=0;
  910.                 x=rand()%winnermax;
  911.                 sprintf(&path[winneransi][13],"%2.2d",x);
  912.                 print_text(winneransi);
  913.                 returner();
  914.                 print_brett();
  915.             }
  916.             if(ptr->all->olg[game-50].status[akt_user-1]==2)
  917.             {
  918.                 ptr->all->olg[game-50].status[akt_user-1]=0;
  919.                 x=rand()%losermax;
  920.                 sprintf(&path[loseransi][12],"%2.2d",x);
  921.                 print_text(loseransi);
  922.                 returner();
  923.                 print_brett();
  924.             }
  925.         }
  926.     }
  927. }
  928.  
  929. void open_wall(BOOL display)
  930. {
  931.     sprintf(&path[wallspfad][6],"%2.2d",game_print);
  932.     i=0;
  933.     make_path(wallspfad);
  934.     if(fp=fopen(pathwork,"r"))
  935.     {
  936.         while (fgets(wall[i],sizeof(wall[0]),fp))
  937.         {
  938.             if(display)
  939.             {
  940.                 PutText(wall[i]);
  941.             }
  942.             i++;
  943.         }
  944.         fclose(fp);
  945.     }
  946. }
  947.  
  948. void get_wall(void)
  949. {
  950.     PutText("55HCFWC7all");
  951.     print_text(wallansi);
  952.  
  953.     PutText("1H");
  954.  
  955.     open_wall(TRUE);
  956.  
  957.     sprintf(line_a,"17H%-8.8s: ",z->user1.Handle);
  958.     PutText(line_a);
  959.  
  960.     if(EnterLine(32,4096,""))
  961.     {
  962.         make_path(wallspfad);
  963.         if(fp=fopen(pathwork,"w"))
  964.         {
  965.             for(y=0;y<ptr->all->game[game].anzahl;y++)
  966.             {
  967.                 ptr->all->game[game].player[y].last_wall_lese='x';
  968.             }
  969.  
  970.             sprintf(line_a,"C%-8.8s: %s\n",z->user1.Handle,z->InBuffer);
  971.  
  972.             for(j=0;j<=i-1;j++)
  973.             {
  974.                 if(j!=0 || i!=12)
  975.                 {
  976.                     fputs(wall[j],fp);
  977.                 }
  978.             }
  979.             fputs(line_a,fp);
  980.  
  981.             fclose(fp);
  982.         }
  983.     }
  984.     if(akt_user<7)
  985.     {
  986.         ptr->all->game[game].player[akt_user-1].last_wall_lese=' ';
  987.     }
  988.  
  989.     PutText("");
  990.     print_brett();
  991. }
  992.  
  993. void cursor(void)
  994. {
  995.     if(ansidesign)
  996.     {
  997.         sprintf(line_a,"C7%d;%dH³%d;%dHC%1x<",alty*2+ytab+15,altx*3+xtab+4,y*2+ytab+15,x*3+xtab+4,akt_user+8);
  998.     }
  999.     else
  1000.     {
  1001.         sprintf(line_a,"%d;%dH %d;%dHC%1x<",alty*2+ytab+15,altx*4+xtab+4,y*2+ytab+15,x*4+xtab+4,akt_user+8);
  1002.     }
  1003.     PutText(line_a);
  1004. }
  1005.  
  1006. void print_fuellgrad(BYTE xt, BYTE yt, BYTE akt_usert, BYTE fuellgrad)
  1007. {
  1008.     if(ansidesign)
  1009.     {
  1010.         sprintf(line_a,"C%1x%d;%dH%2.2s",akt_usert+8,yt*2+ytab+15,xt*3+xtab+2,batzen+(fuellgrad-1)*2);
  1011.     }
  1012.     else
  1013.     {
  1014.         sprintf(line_a,"U1C%1x%d;%dH%d",akt_usert+8,yt*2+ytab+15,xt*4+xtab+2,fuellgrad);
  1015.     }
  1016.     PutText(line_a);
  1017. }
  1018.  
  1019. void flute(BYTE xt, BYTE yt)
  1020. {
  1021.     if(ptr->all->game[game].border==0)
  1022.     {
  1023.         if(xt<0) xt=ptr->all->game[game].x_size-1;
  1024.         if(yt<0) yt=ptr->all->game[game].y_size-1;
  1025.         if(xt==ptr->all->game[game].x_size) xt=0;
  1026.         if(yt==ptr->all->game[game].y_size) yt=0;
  1027.     }
  1028.     if(xt>=0 && xt<ptr->all->game[game].x_size && yt>=0 && yt<ptr->all->game[game].y_size && ptr->all->game[game].fuellgrad[xt][yt]<3)
  1029.     {
  1030.         ptr->all->game[game].fuellgrad[xt][yt]++;
  1031.         ptr->all->game[game].farbe[xt][yt]=akt_user;
  1032.         if(ptr->all->game[game].fuellgrad[xt][yt]==3)
  1033.         {
  1034.             x_flut[stacker]=xt;
  1035.             y_flut[stacker]=yt;
  1036.             stacker++;
  1037.         }
  1038.  
  1039.         print_fuellgrad(xt,yt,akt_user,ptr->all->game[game].fuellgrad[xt][yt]);
  1040.  
  1041.         if(game>49)
  1042.         {
  1043.             ptr->all->olg[game-50].fluter[ptr->all->olg[game-50].pointer+1].xpos=xt;
  1044.             ptr->all->olg[game-50].fluter[ptr->all->olg[game-50].pointer+1].ypos=yt;
  1045.             ptr->all->olg[game-50].fluter[ptr->all->olg[game-50].pointer+1].akt_user=akt_user;
  1046.             ptr->all->olg[game-50].fluter[ptr->all->olg[game-50].pointer+1].fuellgrad=ptr->all->game[game].fuellgrad[xt][yt];
  1047.             ptr->all->olg[game-50].pointer++;
  1048.         }
  1049.     }
  1050. }
  1051.  
  1052. void fuelle(BYTE xt, BYTE yt)
  1053. {
  1054.     ptr->all->game[game].farbe[xt][yt]=akt_user;
  1055.     ptr->all->game[game].fuellgrad[xt][yt]++;
  1056.  
  1057.     print_fuellgrad(xt,yt,akt_user,ptr->all->game[game].fuellgrad[xt][yt]);
  1058.  
  1059.     if(game>49)
  1060.     {
  1061.         ptr->all->olg[game-50].fluter[ptr->all->olg[game-50].pointer+1].xpos=xt;
  1062.         ptr->all->olg[game-50].fluter[ptr->all->olg[game-50].pointer+1].ypos=yt;
  1063.         ptr->all->olg[game-50].fluter[ptr->all->olg[game-50].pointer+1].akt_user=akt_user;
  1064.         ptr->all->olg[game-50].fluter[ptr->all->olg[game-50].pointer+1].fuellgrad=ptr->all->game[game].fuellgrad[xt][yt];
  1065.         ptr->all->olg[game-50].pointer++;
  1066.     }
  1067.  
  1068.     ptr->punkte=0;
  1069.     if(ptr->all->game[game].fuellgrad[xt][yt]==3)
  1070.     {
  1071.         x_flut[0]=xt;
  1072.         y_flut[0]=yt;
  1073.         stacker=1;
  1074.  
  1075.         do
  1076.         {
  1077.             stacker--;
  1078.             ptr->punkte++;;
  1079.             xt=x_flut[stacker];
  1080.             yt=y_flut[stacker];    
  1081.  
  1082.             if(ptr->all->game[game].status==4)
  1083.             {
  1084.                 flute(xt-1,yt);
  1085.                 flute(xt+1,yt);
  1086.                 flute(xt,yt-1);
  1087.                 flute(xt,yt+1);
  1088.             }
  1089.             else
  1090.             {
  1091.                 flute(xt-1,yt-1);
  1092.                 flute(xt+1,yt+1);
  1093.                 flute(xt+1,yt-1);
  1094.                 flute(xt-1,yt+1);
  1095.             }
  1096.         }
  1097.         while(stacker>0);
  1098.     }
  1099. }
  1100.  
  1101. void returner()
  1102. {
  1103.     key[0]=0;
  1104.     do
  1105.     {
  1106.         key[0]=WaitForInput(500000);
  1107.         print_changes();
  1108.     }
  1109.     while (key[0]==0 && z->TimeLeft!=0);
  1110. }
  1111.  
  1112. void killgame(void)
  1113. {
  1114.     for(i=0;i<ptr->all->game[game].x_size;i++)
  1115.     {
  1116.         for(j=0;j<ptr->all->game[game].y_size;j++)
  1117.         {
  1118.             ptr->all->game[game].farbe[i][j]=0;
  1119.             ptr->all->game[game].fuellgrad[i][j]=0;
  1120.         }
  1121.     }
  1122.  
  1123.     for(i=0;i<6;i++)
  1124.     {
  1125.         ptr->all->game[game].player[i].userid=0;
  1126.     }
  1127.  
  1128.     ptr->all->game[game].anzahl=0;
  1129.     ptr->all->game[game].x_size=0;
  1130.     ptr->all->game[game].y_size=0;
  1131.     join[game]=TRUE;
  1132. }
  1133.  
  1134. void turner(void)
  1135. {
  1136.     if(game_print>0 && turn[game])
  1137.     {
  1138.         x=altx;
  1139.         y=alty;
  1140.  
  1141.         cursor();
  1142.  
  1143.         ready=FALSE;
  1144.  
  1145.         key[0]=0;
  1146.         do
  1147.         {
  1148.             key[0]=WaitForInput(500000);
  1149.             print_changes();
  1150.             switch (key[0])
  1151.             {
  1152.                 case 'A':
  1153.                 {
  1154.                     altx=x;
  1155.                     alty=y;
  1156.                     if(y>0?(y--):(y=ptr->all->game[game].y_size-1));
  1157.                     cursor();
  1158.                     break;
  1159.                 }
  1160.                 case 'B':
  1161.                 {
  1162.                     altx=x;
  1163.                     alty=y;
  1164.                     if(y<(ptr->all->game[game].y_size-1)?(y++):(y=0));
  1165.                     cursor();
  1166.                     break;
  1167.                 }
  1168.                 case 'C':
  1169.                 {
  1170.                     altx=x;
  1171.                     alty=y;
  1172.                     if(x<(ptr->all->game[game].x_size-1)?(x++):(x=0));
  1173.                     cursor();
  1174.                     break;
  1175.                 }
  1176.                 case 'D':
  1177.                 {
  1178.                     altx=x;
  1179.                     alty=y;
  1180.                     if(x>0?(x--):(x=ptr->all->game[game].x_size-1));
  1181.                     cursor();
  1182.                     break;
  1183.                 }
  1184.                 case 13:
  1185.                 {
  1186.                     if((ptr->all->game[game].farbe[x][y]!=akt_user && ptr->all->game[game].fuellgrad[x][y]!=0) || ptr->all->game[game].fuellgrad[x][y]>2)
  1187.                     {
  1188.                         if(ptr->all->game[game].farbe[x][y]!=akt_user && ptr->all->game[game].fuellgrad[x][y]!=0)
  1189.                         {
  1190.                             scrollx(infoline,"oh no - select your own ones!");
  1191.                         }
  1192.                         else
  1193.                         {
  1194.                             if(ptr->all->game[game].fuellgrad[x][y]>2)
  1195.                             {
  1196.                                 scrollx(infoline,"oh no - this one is full!");
  1197.                             }
  1198.                         }
  1199.                     }
  1200.                     else
  1201.                     {
  1202.                         ready=TRUE;
  1203.                     }
  1204.                 }
  1205.             }
  1206.         }
  1207.         while (!ready && z->TimeLeft!=0);
  1208.  
  1209.         if(ansidesign)
  1210.         {
  1211.             sprintf(line_a,"C7%d;%dH³",y*2+ytab+15,x*3+xtab+4);
  1212.         }
  1213.         else
  1214.         {
  1215.             sprintf(line_a,"%d;%dH ",y*2+ytab+15,x*4+xtab+4);
  1216.         }
  1217.         PutText(line_a);
  1218.  
  1219.         if(ready)
  1220.         {
  1221.             altx=x;
  1222.             alty=y;
  1223.  
  1224.             fuelle(x,y);
  1225.  
  1226.             if(game>49)
  1227.             {
  1228.                 ptr->olgpointer=ptr->all->olg[game-50].pointer;
  1229.             }
  1230.  
  1231.  
  1232.             PutText("");
  1233.  
  1234.             if(today-ptr->all->game[game].player[akt_user-1].last_move>=86400*3)
  1235.             {
  1236.                 ptr->all->game[game].player[akt_user-1].last_move=today-86400;
  1237.             }
  1238.             else
  1239.             {
  1240.                 ptr->all->game[game].player[akt_user-1].last_move=today;
  1241.             }
  1242.             
  1243.             print_players();
  1244.  
  1245.             count_eimer();
  1246.  
  1247.             gesamt_voll=0;
  1248.             groesster=0;
  1249.  
  1250.             for(y=0;y<ptr->all->game[game].anzahl;y++)
  1251.             {
  1252.                 ptr->status[y]=0;
  1253.                 gesamt_voll+=anz_eimer[2][y];
  1254.                 if(anz_eimer[2][y]>=groesster)
  1255.                 {
  1256.                     zweiter=groesster;
  1257.                     groesster=anz_eimer[2][y];
  1258.                 }
  1259.                 else
  1260.                 {
  1261.                     if(anz_eimer[2][y]>zweiter)
  1262.                     {
  1263.                         zweiter=anz_eimer[2][y];
  1264.                     }
  1265.                 }
  1266.             }
  1267.  
  1268.             for(y=0;y<6;y++)
  1269.             {
  1270.                 if(y<ptr->all->game[game].anzahl)
  1271.                 {
  1272.                     ptr->name[y]=&username[y][0];
  1273.                 }
  1274.                 else
  1275.                 {
  1276.                     ptr->name[y]=&leer[0];
  1277.                 }
  1278.             }
  1279.  
  1280.             if(zweiter+max_eimer-gesamt_voll<groesster || max_eimer==gesamt_voll)
  1281.             {
  1282.                 for(y=0;y<6;y++)
  1283.                 {
  1284.                     if(anz_eimer[2][y]==groesster)
  1285.                     {
  1286.                         ptr->status[y]=1;
  1287.                     }
  1288.                     else
  1289.                     {
  1290.                         ptr->status[y]=2;
  1291.                     }
  1292.                 }
  1293.             }
  1294.  
  1295.             if(game>49)
  1296.             {
  1297.                 PutText("1H         ");
  1298.                 turn[game]=FALSE;
  1299.             }
  1300.  
  1301.             ptr->akt_user=akt_user;
  1302.             send_message(MSG_SCORES);
  1303.  
  1304.             print_players();
  1305.  
  1306.             if(zweiter+max_eimer-gesamt_voll<groesster || max_eimer==gesamt_voll)
  1307.             {
  1308.                 turn[game]=FALSE;
  1309.                 if(game>49)
  1310.                 {
  1311.                     ptr->all->olg[game-50].status[akt_user-1]=0;
  1312.                     ptr->all->olg[game-50].akt_user=0;
  1313.                 }
  1314.                 if(anz_eimer[2][akt_user-1]==groesster)
  1315.                 {
  1316.                     x=rand()%winnermax;
  1317.                     sprintf(&path[winneransi][13],"%2.2d",x);
  1318.                     print_text(winneransi);
  1319.                 }
  1320.                 else
  1321.                 {
  1322.                     x=rand()%losermax;
  1323.                     sprintf(&path[loseransi][12],"%2.2d",x);
  1324.                     print_text(loseransi);
  1325.                 }
  1326.                 returner();
  1327.  
  1328.                 if(ptr->result)
  1329.                 {
  1330.                     print_hall();
  1331.                 }
  1332.                 else
  1333.                 {
  1334.                     print_brett();
  1335.                 }
  1336.  
  1337.                 if(game<50)
  1338.                 {
  1339.                     open_wall(FALSE);
  1340.                     make_path(wallspfad);
  1341.                     if(fp=fopen(pathwork,"w"))
  1342.                     {
  1343.                         for(j=0;j<=i-1;j++)
  1344.                         {
  1345.                             if(j!=0 || i!=12)
  1346.                             {
  1347.                                 fputs(wall[j],fp);
  1348.                             }
  1349.                         }
  1350.                         fputs("C------------------------------------------\n",fp);
  1351.                         fclose(fp);
  1352.                     }
  1353.                     killgame();
  1354.                 }
  1355.             }
  1356.             else
  1357.             {
  1358.                 if(game>49)
  1359.                 {
  1360.                     do
  1361.                     {
  1362.                         if(ptr->all->olg[game-50].akt_user==ptr->all->game[game].anzahl)
  1363.                         {
  1364.                             ptr->all->olg[game-50].akt_user=1;
  1365.                         }
  1366.                         else
  1367.                         {
  1368.                             ptr->all->olg[game-50].akt_user++;
  1369.                         }
  1370.                     }
  1371.                     while(anz_angefasst==max_eimer && anz_eimer[0][ptr->all->olg[game-50].akt_user-1]+anz_eimer[1][ptr->all->olg[game-50].akt_user-1]==0);
  1372.                 }
  1373.                 if(ptr->result)
  1374.                 {
  1375.                     print_hall();
  1376.                 }
  1377.             }
  1378.             if(game<50)
  1379.             {
  1380.                 print_games();
  1381.             }
  1382.             print_status();
  1383.  
  1384.         }
  1385.     }
  1386. }
  1387.  
  1388. void joiner(void)
  1389. {
  1390.     akt_user=0;
  1391.     while(ptr->all->game[game].player[akt_user].userid!=0 && ptr->all->game[game].anzahl>0)
  1392.     {
  1393.         if(game>49)
  1394.         {
  1395.             ptr->all->game[game].player[akt_user].last_move=today;
  1396.         }
  1397.         else
  1398.         {
  1399.             ptr->all->game[game].player[akt_user].last_move=today-86400;
  1400.         }
  1401.         akt_user++;
  1402.     }
  1403.     ptr->all->game[game].player[akt_user].userid=z->id;
  1404.  
  1405.     if(game>49)
  1406.     {
  1407.         ptr->all->game[game].player[akt_user].last_move=today;
  1408.     }
  1409.     else
  1410.     {
  1411.         ptr->all->game[game].player[akt_user].last_move=today-86400;
  1412.     }
  1413.  
  1414.     akt_user++;
  1415.  
  1416.     join[game]=FALSE;
  1417.  
  1418.     if(ptr->all->game[game].anzahl==0)
  1419.     {
  1420.         print_text(layoutansi);
  1421.  
  1422.         ptr->all->game[game].status=4;
  1423.         ptr->all->game[game].border=1;
  1424.         ptr->all->game[game].x_size=12;
  1425.         ptr->all->game[game].y_size=6;
  1426.         ptr->all->game[game].anzahl=4;
  1427.  
  1428.         key[0]=0;
  1429.         do
  1430.         {
  1431.             key[0]=WaitForInput(500000);
  1432.  
  1433.             print_changes();
  1434.  
  1435.             if(key[0]>49 && key[0]<55)
  1436.             {
  1437.                 ptr->all->game[game].anzahl=key[0]-48;
  1438.                 key[0]='?';
  1439.             }
  1440.  
  1441.             switch (key[0])
  1442.             {
  1443.                 case 'g':
  1444.                 {
  1445.                     if(ptr->all->game[game].status==8)
  1446.                     {
  1447.                         ptr->all->game[game].status=4;
  1448.                         PutText("27HNormal");
  1449.                     }
  1450.                     else
  1451.                     {
  1452.                         ptr->all->game[game].status=8;
  1453.                         PutText("27HX-Flut");
  1454.                     }
  1455.                     break;
  1456.                 }
  1457.                 case 'b':
  1458.                 {
  1459.                     if(ptr->all->game[game].border==0)
  1460.                     {
  1461.                         ptr->all->game[game].border=1;
  1462.                         PutText("53HYes");
  1463.                     }
  1464.                     else
  1465.                     {
  1466.                         ptr->all->game[game].border=0;
  1467.                         PutText("53HNo ");
  1468.                     }
  1469.                     break;
  1470.                 }
  1471.                 case 'A':
  1472.                 {
  1473.                     if(ptr->all->game[game].y_size<8) ptr->all->game[game].y_size++;
  1474.                     sprintf(line_a,"42H%2.2d",ptr->all->game[game].y_size);
  1475.                     PutText(line_a);
  1476.                     break;
  1477.                 }
  1478.                 case 'B':
  1479.                 {
  1480.                     if(ptr->all->game[game].y_size>4) ptr->all->game[game].y_size--;
  1481.                     sprintf(line_a,"42H%2.2d",ptr->all->game[game].y_size);
  1482.                     PutText(line_a);
  1483.                     break;
  1484.                 }
  1485.                 case 'C':
  1486.                 {
  1487.                     if(ptr->all->game[game].x_size<20) ptr->all->game[game].x_size++;
  1488.                     sprintf(line_a,"37H%2.2d",ptr->all->game[game].x_size);
  1489.                     PutText(line_a);
  1490.                     break;
  1491.                 }
  1492.                 case 'D':
  1493.                 {
  1494.                     if(ptr->all->game[game].x_size>4) ptr->all->game[game].x_size--;
  1495.                     sprintf(line_a,"37H%2.2d",ptr->all->game[game].x_size);
  1496.                     PutText(line_a);
  1497.                     break;
  1498.                 }
  1499.                 case '?':
  1500.                 {
  1501.                     sprintf(line_a,"30H%d",ptr->all->game[game].anzahl);
  1502.                     PutText(line_a);
  1503.                     break;
  1504.                 }
  1505.             }
  1506.         }
  1507.         while (key[0]!=13 && z->TimeLeft!=0);
  1508.  
  1509.         PutText("");
  1510.  
  1511.         for(y=0;y<ptr->all->game[game].anzahl;y++)
  1512.         {
  1513.             if(game>49)
  1514.             {
  1515.                 ptr->all->olg[game-50].status[y]=0;
  1516.             }
  1517.             ptr->all->game[game].player[y].last_wall_lese=' ';
  1518.         }
  1519.  
  1520.         if(game>49)
  1521.         {
  1522.             ptr->all->olg[game-50].akt_user=1;
  1523.             ptr->all->olg[game-50].joined=1;
  1524.             ptr->all->olg[game-50].pointer=0;
  1525.  
  1526.             sprintf(line_a,"I've started OLG #%d (%d players)",game+1,ptr->all->game[game].anzahl);
  1527.             ptr->mess=&line_a[0];
  1528.             send_message(MSG_MESS);
  1529.         }
  1530.  
  1531.         selectorjoin();
  1532.         print_players();
  1533.         print_games();
  1534.         print_status();
  1535.         print_brett();
  1536.     }
  1537.     else
  1538.     {
  1539.         print_players();
  1540.         print_games();
  1541.         print_status();
  1542.     }
  1543. }
  1544.  
  1545. void print_ranks(void)
  1546. {
  1547.     print_text(rankansi);
  1548.     PutText("CFZ1H");
  1549.     for(x=0;x<2;x++)
  1550.     {
  1551.         for(i=0;i<12;i++)
  1552.         {
  1553.             tab[i].wert=0;
  1554.             tab[i].ptr=0;
  1555.         }
  1556.         i=0;
  1557.         while(ptr->all->user[i].userid>0)
  1558.         {
  1559.             for(j=0;j<10;j++)
  1560.             {
  1561.                 if(ptr->all->user[i].points[x]>=tab[j].wert || tab[j].ptr==0)
  1562.                 {
  1563.                     for(k=9;k>=j;k--)
  1564.                     {
  1565.                         tab[k+1].wert=tab[k].wert;
  1566.                         tab[k+1].ptr=tab[k].ptr;
  1567.                     }
  1568.                     tab[j].wert=ptr->all->user[i].points[x];
  1569.                     tab[j].ptr=i+1;
  1570.                     j=9;
  1571.                 }
  1572.             }
  1573.             if(ptr->all->user[i].userid==z->id)
  1574.             {
  1575.                 tab[11].wert=ptr->all->user[i].points[x];
  1576.                 tab[11].ptr=i+1;
  1577.             }
  1578.             i++;
  1579.         }
  1580.         rankyes=FALSE;
  1581.         for(i=0;i<10;i++)
  1582.         {
  1583.             if(tab[i].ptr==0)
  1584.             {
  1585.                 sprintf(line_a,"%d;%dHno one...",16+i,9+x*36);
  1586.             }
  1587.             else
  1588.             {
  1589.                 if(ptr->all->user[tab[i].ptr-1].userid==z->id)
  1590.                 {
  1591.                     rankyes=TRUE;
  1592.                 }
  1593.                 if(ReadAccount(ptr->all->user[tab[i].ptr-1].userid,&z->user2))
  1594.                 {
  1595.                     sprintf(line_a,"%d;%dH%-20.20s %5d",16+i,9+x*36,z->user2.Handle,tab[i].wert);
  1596.                 }
  1597.             }
  1598.             PutText(line_a);
  1599.         }
  1600.         if(tab[11].ptr!=0 && !rankyes)
  1601.         {
  1602.             sprintf(line_a,"%dH%-20.20s %5d",9+x*36,z->user1.Handle,tab[11].wert);
  1603.             PutText(line_a);
  1604.         }
  1605.         PutText("Z4");
  1606.     }
  1607.     PutText("");
  1608.     returner();
  1609.     print_brett();
  1610. }
  1611.  
  1612. void print_hall(void)
  1613. {
  1614.     print_text(hallansi);
  1615.     for(x=0;x<2;x++)
  1616.     {
  1617.         PutText("Z7C01H");
  1618.         for(y=0;y<10;y++)
  1619.         {
  1620.             PutText(ptr->all->fame.hall[x][y]);
  1621.         }
  1622.     }
  1623.     PutText("Z0");
  1624.     returner();
  1625.     print_brett();
  1626. }
  1627.  
  1628. void fluter(long fluterid)
  1629. {
  1630.     if(ReadAccount(fluterid,&z->user2))
  1631.     {
  1632.         if(z->user2.Handle[0]!='!');
  1633.         {
  1634.             sprintf(line_a,"%-10d%-10d%s\n",fluterid,z->user2.IDNumber,z->user2.Handle);
  1635.             fputs(line_a,fp);
  1636.         }
  1637.     }
  1638. }
  1639.  
  1640. void operator(void)
  1641. {
  1642.     print_text(chefansi);
  1643.  
  1644.     key[0]=0;
  1645.     do
  1646.     {
  1647.         key[0]=WaitForInput(500000);
  1648.  
  1649.         print_changes();
  1650.  
  1651.         switch (key[0])
  1652.         {
  1653.             case 'd':
  1654.             {
  1655.                 if(game>-1)
  1656.                 {
  1657.                     killgame();
  1658.  
  1659.                     selectorjoin();
  1660.                     print_players();
  1661.                     print_games();
  1662.                     print_status();
  1663.                 }
  1664.                 break;
  1665.             }
  1666.             case 't':
  1667.             {
  1668.                 print_text(testansi);
  1669.                 returner();
  1670.                 break;
  1671.             }
  1672.             case 'c':
  1673.             {
  1674.                 PutText("33H");
  1675.                 if(EnterLine(2,4096,""))
  1676.                 {
  1677.                     game_sysop=atoi(z->InBuffer);
  1678.                 }
  1679.                 else
  1680.                 {
  1681.                     game_sysop=0;
  1682.                 }
  1683.                 if(game_sysop>=0)
  1684.                 {
  1685.                     if(game_sysop==0)
  1686.                     {
  1687.                         if(fp=fopen(routepfad,"w"))
  1688.                         {
  1689.                             y=0;
  1690.                             while(ptr->all->user[y].userid!=0)
  1691.                             {
  1692.                                 fluter(ptr->all->user[y].userid);
  1693.                                 y++;
  1694.                             }
  1695.                         }
  1696.                     }
  1697.                     else
  1698.                     {
  1699.                         game_sysop--;
  1700.                         if(fp=fopen(routepfad,"w"))
  1701.                         {
  1702.                             for(y=0;y<ptr->all->game[game_sysop].anzahl;y++)
  1703.                             {
  1704.                                 if(ptr->all->game[game_sysop].player[y].userid!=0)
  1705.                                 {
  1706.                                     fluter(ptr->all->game[game_sysop].player[y].userid);
  1707.                                 }
  1708.                             }
  1709.                             fclose(fp);
  1710.                         }
  1711.                     }
  1712.                 }
  1713.                 break;
  1714.             }
  1715.         }
  1716.     }
  1717.     while (key[0]==0 && z->TimeLeft!=0);
  1718.  
  1719.     print_brett();
  1720. }
  1721.  
  1722.  
  1723. void mymain(void)
  1724. {
  1725.     SetDoing("Flut! v4");
  1726.  
  1727.     moremode=z->user1.MoreMode;
  1728.     z->user1.MoreMode=0;
  1729.  
  1730.     print_players();
  1731.     print_games();
  1732.     print_status();
  1733.     print_brett();
  1734.  
  1735.     if(z->SysMaint==1234567890)
  1736.     {
  1737.         scrollx(infoline,"Hi sysop - you've got an extra menu - try 'o' to invoke it           ");
  1738.     }
  1739.  
  1740.     key[0]=0;
  1741.     do
  1742.     {
  1743.         key[0]=WaitForInput(500000);
  1744.  
  1745.         print_changes();
  1746.  
  1747.         switch (key[0])
  1748.         {
  1749.             case '+':
  1750.             {
  1751.                 if(game_print<60?(game_neu=game_print+1):(game_neu=1));
  1752.                 select();
  1753.                 break;
  1754.             }
  1755.             case '-':
  1756.             {
  1757.                 if(game_print>1?(game_neu=game_print-1):(game_neu=60));
  1758.                 select();
  1759.                 break;
  1760.             }
  1761.             case 'a':
  1762.             {
  1763.                 game_neu=game_print;
  1764.                 do
  1765.                 {
  1766.                     if(game_neu<60?(game_neu++):(game_neu=0));
  1767.                 }
  1768.                 while((!turn[game_neu-1] || game_neu==0) && game_neu!=game_print);
  1769.  
  1770.                 if(game_neu!=game)
  1771.                 {
  1772.                     select();
  1773.                 }
  1774.                 break;
  1775.             }
  1776.             case 'c':
  1777.             {
  1778.                 print_clock();
  1779.                 break;
  1780.             }
  1781.             case 'm':
  1782.             {
  1783.                 reading=TRUE;
  1784.                 print_text(messansi);
  1785.                 PutText("12H");
  1786.                 if(EnterLine(56,4096,""))
  1787.                 {
  1788.                     ptr->mess=&z->InBuffer[0];
  1789.                     PutText("");
  1790.                     print_changes();
  1791.                     send_message(MSG_MESS);
  1792.                 }
  1793.                 else
  1794.                 {
  1795.                     PutText("");
  1796.                 }
  1797.                 print_brett();
  1798.                 reading=FALSE;
  1799.                 break;
  1800.             }
  1801.             case 'i':
  1802.             {
  1803.                 reading=TRUE;
  1804.                 go=TRUE;
  1805.                 path[helpansi][11]='a';
  1806.  
  1807.                 print_text(helpansi);
  1808.  
  1809.                 do
  1810.                 {
  1811.                     key[0]=WaitForInput(500000);
  1812.                     print_changes();
  1813.  
  1814.                     if(key[0]!=0)
  1815.                     {
  1816.                         if(key[0]>='a' && key[0] <= 'o')
  1817.                         {
  1818.                             if(path[helpansi][11]!=key[0])
  1819.                             {
  1820.                                 path[helpansi][11]=key[0];
  1821.                                 print_text(helpansi);
  1822.                             }
  1823.                         }
  1824.                         else
  1825.                         {
  1826.                             if(key[0]==13)
  1827.                             {
  1828.                                 if(path[helpansi][11]=='o')
  1829.                                 {
  1830.                                     path[helpansi][11]='a';
  1831.                                 }
  1832.                                 else
  1833.                                 {
  1834.                                     path[helpansi][11]++;
  1835.                                 }
  1836.                                 print_text(helpansi);
  1837.                             }
  1838.                             else
  1839.                             {
  1840.                                 go=FALSE;
  1841.                             }
  1842.                         }
  1843.                     }
  1844.                 }
  1845.                 while (go && z->TimeLeft!=0);
  1846.  
  1847.                 print_brett();
  1848.                 reading=FALSE;
  1849.                 break;
  1850.             }
  1851.             case 's':
  1852.             {
  1853.                 PutText("H  D");
  1854.                 if(EnterLine(2,4096,""))
  1855.                 {
  1856.                     game_neu=atoi(z->InBuffer);
  1857.                 }
  1858.                 else
  1859.                 {
  1860.                     game_neu=game_print;
  1861.                 }
  1862.                 select();
  1863.                 break;
  1864.             }
  1865.             case 'w':
  1866.             {
  1867.                 if(game<50)
  1868.                 {
  1869.                     get_wall();
  1870.                 }
  1871.                 break;
  1872.             }
  1873.             case 't':
  1874.             {
  1875.                 turner();
  1876.                 break;
  1877.             }
  1878.             case 'n':
  1879.             {
  1880.                 reading=TRUE;
  1881.                 scrolly("");
  1882.                 scrolly("CBZ4Date     Z0 Z4GameZ0 Z4Points Z0 Z4C9Winner(s)CF/CALoser(s)                                 Z0");
  1883.                 for(y=0;y<15;y++)
  1884.                 {
  1885.                     strcpy(line_a,ptr->all->fame.news[y]);
  1886.                     x=0;
  1887.                     while(line_a[x]!=10 && line_a[x]!=0)
  1888.                     {
  1889.                         x++;
  1890.                     }
  1891.                     line_a[x]=0;
  1892.                     scrolly(line_a);
  1893.                 }
  1894.                 PutText("H");
  1895.                 returner();
  1896.                 print_brett();
  1897.                 reading=FALSE;
  1898.                 break;
  1899.             }
  1900.             case 'd':
  1901.             {
  1902.                 if(ansidesign)
  1903.                 {
  1904.                     scrollx(infoline,"AnsiDesign disabled");
  1905.                 }
  1906.                 else
  1907.                 {
  1908.                     scrollx(infoline,"AnsiDesign enabled");
  1909.                 }
  1910.                 ansidesign=!ansidesign;
  1911.                 tabulator();
  1912.                 if(game_print>0)
  1913.                 {
  1914.                     print_brett();
  1915.                 }
  1916.                 break;
  1917.             }
  1918.             case 'o':
  1919.             {
  1920.                 if(z->SysMaint==1234567890)
  1921.                 {
  1922.                     reading=TRUE;
  1923.                     operator();
  1924.                     reading=FALSE;
  1925.                 }
  1926.                 break;
  1927.             }
  1928.             case 'h':
  1929.             {
  1930.                 reading=TRUE;
  1931.                 print_hall();
  1932.                 reading=FALSE;
  1933.                 break;
  1934.             }
  1935.             case 'r':
  1936.             {
  1937.                 reading=TRUE;
  1938.                 print_ranks();
  1939.                 reading=FALSE;
  1940.                 break;
  1941.             }
  1942.             case 'p':
  1943.             {
  1944.                 break;
  1945.             }
  1946.             case 'j':
  1947.             {
  1948.                 if(game_print>0 && game_print<61 && join[game])
  1949.                 {
  1950.                     reading=TRUE;
  1951.                     joiner();
  1952.                     reading=FALSE;
  1953.                 }
  1954.                 break;
  1955.             }
  1956.         }
  1957.     }
  1958.     while (key[0]!=113 && z->TimeLeft!=0);
  1959.  
  1960.     ptr->timeleft=z->TimeLeft;
  1961.  
  1962.     ptr->game_alt=game;
  1963.     ptr->game_neu=-1;
  1964.     send_message(MSG_GAME);
  1965.  
  1966.     z->user1.MoreMode=moremode;
  1967. }
  1968.